//Τιμοκαταλογος που μπορει να τροποποιησει ενας χρηστης(καταστηματαρχης)
package Controllers;

import DAO.PriceList_Dao;

public class PriceList_Controller {

    PriceList_Controller() {
    }

    public PriceList_Controller(PriceList_Dao priceList_Dao) {
    }

    public boolean validatePriceList(String storename,String fmpoukali, String fpoto, String fmpyra, String fsfinaki, String fmiso, String kmpoukali, String kpoto, String kmpyra, String ksfinaki, String kmiso)
            throws IllegalArgumentException {
        boolean x;
        try {
            if (storename.isEmpty() || fmpoukali.isEmpty() || fpoto.isEmpty() || fmpyra.isEmpty() || fsfinaki.isEmpty() || fmiso.isEmpty() || kmpoukali.isEmpty() || kpoto.isEmpty() || kmpyra.isEmpty() || ksfinaki.isEmpty() || kmiso.isEmpty()) {
                x = false;
            } else if (fmpoukali.matches("[0-9]+") == false || fpoto.matches("[0-9]+") == false || fmpyra.matches("[0-9]+") == false || fsfinaki.matches("[0-9]+") == false || fmiso.matches("[0-9]+") == false || kmpoukali.matches("[0-9]+") == false || kpoto.matches("[0-9]+") == false || kmpyra.matches("[0-9]+") == false || ksfinaki.matches("[0-9]+") == false || kmiso.matches("[0-9]+") == false) {
                x = false;
            } else if (fmpoukali.length() > 3 || kmpoukali.length() > 3 || fpoto.length() > 3 || kpoto.length() > 3 || fmpyra.length() > 3 || kmpyra.length() > 3 || fsfinaki.length() > 3 || ksfinaki.length() >3) {
                x = false;
            } else {
                DAO.PriceList_Dao y = new DAO.PriceList_Dao();
                y.insertPricelist(storename, fmpoukali, fpoto, fmpyra, fsfinaki, fmiso, kmpoukali, kpoto, kmpyra, ksfinaki, kmiso);
                x = true;
            }
        } catch (Exception e) {
            throw new IllegalArgumentException("Error in PriceList_Controller");
        }
        
        return x;
    }

    boolean validatePriceList(String fmpoukali, String fpoto, String fmpyra, String fsfinaki, String fmiso, String kmpoukali, String kpoto, String kmpyra, String ksfinaki, String kmiso) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
}
